extends TextureButton

signal addsun

var target = Vector2(0,0)
const speed = 300
var move = false

func _ready():
	connect("addsun",get_tree().current_scene.get_node("Sun/Label"),"add")
	pass

func _on_Sun_pressed():
	$se.play()
	move = true
	#yield($se,"finished")
	pass
	
func _process(delta):
	if move:
		self.rect_global_position = self.rect_global_position.move_toward(target,speed*delta)
		if self.rect_global_position.distance_to(target) <=0:
			emit_signal("addsun")
			self.queue_free()
	pass
	
func _on_Timer_timeout():
	queue_free()
	pass # Replace with function body.
